export default {
	data() {
		return {
			// 是否隐藏上方切换栏
			hide:null,
			// 记录一共有多少条
			allSize:null,
			current:0,
			// 记录当前页数
			page: 1,
			// 记录总页数
			allPage: null,
			status: 'loadmore',
			// 记录当前的公司cid
			companyCid: null,
			// 变更的信息
			personMsg: [],
			//记录接口信息
			urlMsg: null,
			list1: [{
				name: '主要人员',
			}, {
				name: '注册人员',
			}, {
				name: '资质证书'
			}, {
				name: '企业业绩'
			}, {
				name: '税务等级'
			}]

		}
	},
	onLoad(option) {
		// console.log("______________", option)
		if(option.hide){
			this.hide=option.hide
		}
		// 查询该公司详情
		this.companyCid = option.companyCid
		if (option.index == 2) {
			
			this.current=0
		} else if (option.index == 3) {
			this.current=1
		}else if(option.index == 4){
			this.current=2
		}else if(option.index == 5){
			this.current=3
		}else if(option.index == 6){
			this.current=4
		}
		this.sureUrl()
		// 根据传进来的参数判断 是查询哪个接口


	},
	onReachBottom() {
		// console.log("-----------", this.page, this.allPage)
		if (this.page >= this.allPage) {
			this.status = 'nomore';
			return
		}
		this.status = 'loading';
		this.page = ++this.page;
		setTimeout(() => {
			this.checkChangeList(this.companyCid)
			if (this.page >=  this.allPage) this.status = 'nomore';
			else this.status = 'loading';
		}, 2000)
	},
	methods: {
		
		       
		// 跳转至查看详情页面
		checkMore(urlMsg){
			// 将链接保存至本地
				uni.setStorageSync('companyUrl', urlMsg);
			uni.navigateTo({
				url:`/pagesFind/detailenterprise/recordPage/recordPage?companyBidOriUrl=0`
			})
		},
		
		// 点击标签
		tagClick(item){
			
			this.current=item.index
			// 
			this.sureUrl()
		},
		sureUrl(){
			if(this.current==0){
				this.urlMsg = this.$baseApp.api.dicData.companyMainStuffList
			}else if(this.current==1){
				this.urlMsg = this.$baseApp.api.dicData.companyRegisteredPersonnelDetailsList
			}else if(this.current==2){
				this.urlMsg = this.$baseApp.api.dicData.companyQualificationDetailsList
			}else if(this.current==3){
				this.urlMsg = this.$baseApp.api.dicData.companyProjectDetailsList
			}else if(this.current==4){
				this.urlMsg = this.$baseApp.api.dicData.companyCreditRateList
			}
			this.page=1
			this.personMsg=[]
			this.checkChangeList(this.companyCid)
		},
		// 查询该公司主要人员
		checkChangeList(id) {
			this.$app.request({
				url: this.urlMsg,
				data: {
					'companyCid': id,
					'page': this.page
				},
				method: 'GET',
				dataType: 'json',
				success: res => {
					if (res.code == 200) {
						// console.log("++++++res+++++++", res);
						this.allPage = res.data.totalPages
						this.allSize=res.data.totalElements
						if (this.allPage<= 1||res.data.content.length<10) {
							this.status = 'nomore'
						}
						// 主要人员  current=0
						if(this.current==0){
							res.data.content.forEach((item) => {
								if (item.companyTagList[0]) {
									item.tagList = item.companyTagList[0].name
								}
							
								this.personMsg.push(item)
							})
						}else if(this.current==1){
							res.data.content.forEach((item) => {
								if (item.companyRegInfo) {
									item.tagList = item.companyRegInfo[0]
								}
								item.name = item.companyHumanName.slice(0, 1)
								this.personMsg.push(item)
							})
						}else if(this.current==2){
							// console.log("res资质信息",res)
							let str
							res.data.content.forEach((item) => {
							if(item.companyQualification.companyQualificationName){
								str=item.companyQualification.companyQualificationName
								item.companyQualification.companyQualificationName=str.split(',')
								// console.log("item.companyQualification.companyQualificationName",item.companyQualification.companyQualificationName)
							}
							if(item.companyCertificate.companyQualificationRange){
								str=item.companyCertificate.companyQualificationRange
								item.companyCertificate.companyQualificationRange=str.split(',')
								// console.log("item.companyCertificate.companyQualificationRange",item.companyCertificate.companyQualificationRange)
							}
								this.personMsg.push(item)
							})
						}else if(this.current==3){
							res.data.content.forEach((item) => {
								item.companyBaseInfo=JSON.parse(item.companyBaseInfo)
								
								this.personMsg.push(item)
							})
						}else {
							res.data.content.forEach((item) => {
								
								this.personMsg.push(item)
							})
						}
						// console.log("-------------------", this.personMsg)

					}
					
				},
				complete: res => {
					uni.stopPullDownRefresh();
					
				}
			});
		},
	}
}
